#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
const int N = 10005;
struct node {
	int v, dis;
	node (int vi, int disi) {
		v = vi;
		dis = disi;
	}
};
vector <node> g[N];
int maxd = -1, maxi;
bool vis[N];
void dfs (int u, int d) {
	if (vis[u]) {
		return;
	}
	vis[u] = 1;
	if (maxd < d) {
		maxd = d;
		maxi = u;
	}
	for (unsigned i = 0; i < g[u].size(); i++) {
		dfs (g[u][i].v, d + g[u][i].dis);
	}
}
int main() {
	int x, y, k;
	string str;
	stringstream ss;
	while (!cin.eof()) {
		while (1) {
			str = "";
			ss.clear();
			for (int i = 1; i <= N; i++) {
				g[i].clear();
			}
			getline (cin, str);
			if (str.size() == 0) {
				break;
			}
			ss.str(str);
			ss >> x >> y >> k;
			g[x].push_back(node(y, k));
			g[y].push_back(node(x, k));
		}
		dfs(1, 0);
		dfs (maxi, 0);
		printf ("%d\n", maxd);
	}
	return 0;
}